package qz_rpt
import java.text.SimpleDateFormat
class FinalPassYieldByPartController {

    def commonSqlService
    def dynamicQueryService

    def index(Integer max) {
        def cellList = org.kdx.DataUtils.getCellList()
        def pageSizeList = org.kdx.DataUtils.getPageSizeList()

        [totalCount: 5, pageSize: 20, pageCurrent: 1, orderField: 'id', orderDirection: 'asc', pageSizeList: pageSizeList, cellList: cellList]
    }

    def finalPassYieldByPart(){
        def pageCurrent = params.pageCurrent ? Integer.parseInt(params.pageCurrent) : 1
        def pageSize = params.pageSize ? Integer.parseInt(params.pageSize) : 10
        params.startno = ((pageCurrent - 1) * pageSize) + 1
        params.endno = pageCurrent * pageSize
        def finalPassYieldByPart=[]
        def finalPassYieldByPartTen=[]
        def pageSizeList = [10,20,50,100]
        def totalCount =0
        def tableHeadList = []
         SimpleDateFormat sdf = new SimpleDateFormat('yyyy-MM-dd')
         def startTime = params.startTime ? sdf.parse(params.startTime) : sdf.parse(sdf.format(new Date().clearTime()))
         def endTime = params.endTime ? sdf.parse(params.endTime) : sdf.parse(sdf.format(new Date()))
         params.startTime = sdf.format(startTime)
         params.endTime = sdf.format(endTime)
//        def customerLotIdList = commonSqlService.customerLotIdList(params)
        params.SYS_QUERY_NAME = 'checkStepList'
        def checkStepList = dynamicQueryService.queryForList(params)
        params.SYS_QUERY_NAME = 'partDirect'
        def partDirect = dynamicQueryService.queryForList(params)
        if(params.EXPORT_CONTENT_NAME=='Excel'){
            params.SYS_QUERY_NAME = 'finalPassYieldByPart'
            finalPassYieldByPart = dynamicQueryService.queryForList(params)

            params.SYS_QUERY_NAME = 'finalPassYieldByPartTen'
            finalPassYieldByPartTen = dynamicQueryService.queryForList(params)
            if (finalPassYieldByPart.size() > 0) {
                tableHeadList = finalPassYieldByPart[0].keySet()
            }
           /* params.SYS_QUERY_NAME = 'oncePassYieldByPartCount'
            totalCount = dynamicQueryService.queryForList(params)[0].TOTALCOUNT*/
        }



        [pageSize  : pageSize, pageSizeList: pageSizeList, startno: params.startno ?: '', endno: params.endno ?: '',partDirect:partDirect,
         /*totalCount: totalCount,*/ tableHeadList: tableHeadList,checkStepList:checkStepList,
//         customerLotIdList:customerLotIdList,
         group4: params.group4 ?: '', group3: params.group3 ?: '',defectType:params.defectType?:'',checkStep:params.checkStep?:'',
         startTime:params.startTime?:'',endTime:params.endTime?:'',customerDirect:params.customerDirect?:'',customerLotId:params.customerLotId?:'',
         finalPassYieldByPart:finalPassYieldByPart,finalPassYieldByPartTen:finalPassYieldByPartTen]

    }
}
